home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / share / aclocal-1.5 / ccstdc.m4 < prev    next >
Encoding:
M4 Source File  |  2005-10-16  |  2.8 KB  |  93 lines

  1. ## ----------------------------------------- ##
  2. ## ANSIfy the C compiler whenever possible.  ##
  3. ## From Franc,ois Pinard                     ##
  4. ## ----------------------------------------- ##
  5.  
  6. # serial 1
  7.  
  8. # @defmac AC_PROG_CC_STDC
  9. # @maindex PROG_CC_STDC
  10. # @ovindex CC
  11. # If the C compiler in not in ANSI C mode by default, try to add an option
  12. # to output variable @code{CC} to make it so.  This macro tries various
  13. # options that select ANSI C on some system or another.  It considers the
  14. # compiler to be in ANSI C mode if it handles function prototypes correctly.
  15. #
  16. # If you use this macro, you should check after calling it whether the C
  17. # compiler has been set to accept ANSI C; if not, the shell variable
  18. # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
  19. # code in ANSI C, you can make an un-ANSIfied copy of it by using the
  20. # program @code{ansi2knr}, which comes with Ghostscript.
  21. # @end defmac
  22.  
  23. AC_DEFUN([AM_PROG_CC_STDC],
  24. [AC_REQUIRE([AC_PROG_CC])
  25. AC_BEFORE([$0], [AC_C_INLINE])
  26. AC_BEFORE([$0], [AC_C_CONST])
  27. dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
  28. dnl a magic option to avoid problems with ANSI preprocessor commands
  29. dnl like #elif.
  30. dnl FIXME: can't do this because then AC_AIX won't work due to a
  31. dnl circular dependency.
  32. dnl AC_BEFORE([$0], [AC_PROG_CPP])
  33. AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
  34. AC_CACHE_VAL(am_cv_prog_cc_stdc,
  35. [am_cv_prog_cc_stdc=no
  36. ac_save_CC="$CC"
  37. # Don't try gcc -ansi; that turns off useful extensions and
  38. # breaks some systems' header files.
  39. # AIX            -qlanglvl=ansi
  40. # Ultrix and OSF/1    -std1
  41. # HP-UX 10.20 and later    -Ae
  42. # HP-UX older versions    -Aa -D_HPUX_SOURCE
  43. # SVR4            -Xc -D__EXTENSIONS__
  44. for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
  45. do
  46.   CC="$ac_save_CC $ac_arg"
  47.   AC_TRY_COMPILE(
  48. [#include <stdarg.h>
  49. #include <stdio.h>
  50. #include <sys/types.h>
  51. #include <sys/stat.h>
  52. /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
  53. struct buf { int x; };
  54. FILE * (*rcsopen) (struct buf *, struct stat *, int);
  55. static char *e (p, i)
  56.      char **p;
  57.      int i;
  58. {
  59.   return p[i];
  60. }
  61. static char *f (char * (*g) (char **, int), char **p, ...)
  62. {
  63.   char *s;
  64.   va_list v;
  65.   va_start (v,p);
  66.   s = g (p, va_arg (v,int));
  67.   va_end (v);
  68.   return s;
  69. }
  70. int test (int i, double x);
  71. struct s1 {int (*f) (int a);};
  72. struct s2 {int (*f) (double a);};
  73. int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
  74. int argc;
  75. char **argv;
  76. ], [
  77. return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
  78. ],
  79. [am_cv_prog_cc_stdc="$ac_arg"; break])
  80. done
  81. CC="$ac_save_CC"
  82. ])
  83. if test -z "$am_cv_prog_cc_stdc"; then
  84.   AC_MSG_RESULT([none needed])
  85. else
  86.   AC_MSG_RESULT([$am_cv_prog_cc_stdc])
  87. fi
  88. case "x$am_cv_prog_cc_stdc" in
  89.   x|xno) ;;
  90.   *) CC="$CC $am_cv_prog_cc_stdc" ;;
  91. esac
  92. ])
  93.